package com.nbicc.service.modular.dp.panelwidgetinstance.service;

import com.nbicc.core.common.RequestPageObj;
import com.nbicc.core.common.ResponseUtil;
import com.nbicc.db.modular.dp.panelwidgetinstance.mapper.PanelWidgetInstanceMapper;
import com.nbicc.db.modular.dp.panelwidgetinstance.model.PanelWidgetInstance;
import com.nbicc.service.parent.serivce.BaseSerivce;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.ui.ModelMap;

import java.util.Map;

/**
 * @Author: lilingyan
 */
@Service
public class PanelWidgetInstanceService extends BaseSerivce{

    @Autowired
    private PanelWidgetInstanceMapper panelWidgetInstanceMapper;

    public ResponseEntity<ModelMap> listByPanelId(Integer panelId) {
        return ResponseUtil.ok(panelWidgetInstanceMapper.listByPanelId(panelId));
    }

    public ResponseEntity<ModelMap> find(RequestPageObj<Map<String, Object>> requestPageObj) {
        setPageHelper(requestPageObj);
        return ResponseUtil.ok(panelWidgetInstanceMapper.selectByObject(requestPageObj.getData()));
    }

    public ResponseEntity<ModelMap> insert(PanelWidgetInstance panelWidgetInstance) {
        panelWidgetInstanceMapper.insert(panelWidgetInstance);
        return ResponseUtil.ok(panelWidgetInstance);
    }

    public ResponseEntity<ModelMap> updateById(PanelWidgetInstance panelWidgetInstance) {
        panelWidgetInstanceMapper.updateById(panelWidgetInstance);
        return ResponseUtil.ok();
    }

    public ResponseEntity<ModelMap> deleteById(String id) {
        panelWidgetInstanceMapper.deleteById(id);
        return ResponseUtil.ok();
    }

}
